﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace cpk_dec
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Format: command [Inputfile]");
                return;
            }
            FileInfo fi = new FileInfo(args[0]);
            DirectoryInfo di = fi.Directory;
            FileInfo fio = new FileInfo(Path.Combine(di.FullName, fi.Name + ".dec"));
            FileStream fout = fio.Create();
            FileStream fin = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fin);

            BitWriter bw = new BitWriter(fout);
            br.BaseStream.Seek(0x100, SeekOrigin.Begin);

            for (int i = 0; i < 0x20; i++)
            {
                byte b = br.ReadByte();
                bw.WriteBit(0, 1);
                bw.WriteBit(b, 8);
            }

            Console.WriteLine("Complete");
            bw.Close();
            br.Close();
        }
    }
}
